/*
 * 企业管理
 */

import { createAPI } from '@/utils/request'

export const list = (params) => createAPI('/companys', 'get', params)
  .then(res => ({
    ...res.data,
    items: res.data.items.map(d => ({
      ...d,
      state: d.state === 0 ? '禁用' : '启用'
    }))
  }))
  .catch(() => {})
export const add = data => createAPI('/companys', 'post', data)
export const update = data => createAPI(`/companys/${data.id}`, 'put', data)
export const remove = data => createAPI(`/companys/${data.id}`, 'delete', data)
export const detail = data => createAPI(`/companys/${data.id}`, 'get', data)
export const disabled = data => createAPI(`/companys/${data.id}/state`, 'post', data)
